home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / WWIV Mods / WWIVMOD.ZIP / GIFINFO.MOD < prev    next >
Encoding:
Text File  |  1993-08-10  |  7.1 KB  |  206 lines

  1. Tue Feb 09 03:04:55 1993
  2.  
  3. Filename       : GIFINFO.MOD
  4. Re-written for : WWIV 4.22
  5. Re-written by  : Snorkel 1@3459 WWIVnet (original author unknown)
  6. Date re-written: 2-9-93
  7. Files affected : BATCH.C
  8.                  XFER.C
  9.                  XFEROVL.C
  10.                  FCNS.H
  11. Function       : Places the size of the .GIF file at the beginning of the file
  12.                  description.  Works either with the command \\UPLOAD or when
  13.                  a remote user uploads a file with a .GIF extension.  Also
  14.                  tells the sysop if the file is not a .GIF (in the sysop log).
  15.  
  16. I have changed the code in this mod to make it more efficient, and also to
  17. look for both the old .GIF format (GIF87a) and the new format (GIF89a).
  18. Additionally, I have added a bit of code to the mod (at the end) so that the
  19. file description is not longer than the comment field when the .GIF dimensions
  20. are added to the file description.  I would like to give the original author
  21. credit for this mod, since he did the hard part of actually writing the
  22. routines which read the size of the .GIF and append the description onto it.
  23. However, in the process of converting this mod over several times, I have lost
  24. the original author's name.
  25.  
  26. This is a simple mod that automatically adds, to the file description, the
  27. dimensions of any .GIF file that is uploaded to your board, remotely or
  28. locally.  The dimensions will be in the format of WWWxHHHxCCC, where WWW is
  29. the width, HHH is the height, and CCC is the number of colors used.  The
  30. output should look like this:
  31.  
  32.  
  33. WORF    .GIF:   21k :320x200x16  ... Lt. Worf of the USS Enterprise.
  34. ALYSA1  .GIF:   59k :320x200x256 ... Lovely brunette with VERY brown eyes.
  35. BRNCORAL.GIF:  173k :640x480x256 ... Brain coral, St. Thomas, U.S.V.I.
  36. SCHIFF05.GIF:   83k :800x600x256 ... Claudia Schiffer in a white swim suit.
  37. EHZS0034.GIF:  659k :1024x768x256 .. Great scan of colorful autumn leaves.
  38.  
  39.  
  40. There is 58 characters total for the description.  With the .GIF size added to
  41. the beginning, the amount of room left for the input of a description changes
  42. to 42 characters.
  43.  
  44. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  45. Step 1
  46.  
  47. FCNS.H
  48.  
  49. Add the following code where indicated.
  50.  
  51. /* File: sr.c */                               /* search for */
  52.  
  53. int getbytes(FILE *dev);                         /* add */
  54. void check_gif(char *fn, char *descript);        /* add */
  55. char *stripfn(char *fn);
  56. void stripfn1(char *fn);
  57. void calc_CRC(unsigned char b);
  58.  
  59. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. Step 2
  61.  
  62. BATCH.C 
  63.  
  64. In function "void uploaded(char *fn, long cps)" add the following code:
  65.  
  66.                 if (d1>=0) {                       /* search for */
  67.                   u.numbytes = filelength(d1);
  68.                   close(d1);
  69.                                                     /* add */
  70.                   if (strstr(u.filename,".GIF"))    /* add */
  71.                     check_gif(s2,u.description);    /* add */
  72.  
  73.                   ++thisuser.uploaded;
  74.  
  75. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. Step 3
  77.  
  78. XFER.C
  79.  
  80. In function "void upload(int dn)" add or change as noted below:
  81.  
  82.   directoryrec d;                          /* search for */
  83.   uploadsrec u,u1;
  84.   int i,i1,i2,i3,i4,ok,xfer,f,w;            /* add "w" */
  85.  
  86.  
  87. Now search for the following line, and add or change the code as indicated
  88. below:
  89.  
  90.       pl(get_string(779));                      /* search for */
  91.       if(strstr(u.filename,".GIF"))                 /* add */
  92.         w=42;                                       /* add */
  93.       else                                          /* add */
  94.         w=58;                                       /* add */
  95.       outstr(": ");                       /* existing code */
  96.       inputl(u.description,w);      /* CHANGED the "58" to "w"*/
  97.       nl();
  98.  
  99.  
  100.        if (ok) {
  101.          if (ok==1) {
  102.          l=filelength(f);                  /* search for */
  103.          u.numbytes=l;
  104.          close(f);                        /* existing code */
  105.          if (strstr(u.filename,".GIF"))        /* add */
  106.            check_gif(s1,u.description);        /* add */
  107.          ++thisuser.uploaded;             /* existing code */
  108.          thisuser.uk += ((l+1023)/1024);
  109.  
  110. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  111. Step 4
  112.  
  113. XFEROVL.C
  114.  
  115. In function "int upload_file(char *fn, int dn, char *desc)" add the following:
  116.  
  117.   directoryrec d;                      /* search for */
  118.   uploadsrec u,u1;
  119.   int i,i1,i2,ok,f,w;                 /* "w" added M&M */
  120.  
  121. Further down in the code, change as follows:
  122.  
  123.      u.description[58]=0;                /* search for */
  124.      pl(u.description);                 /* existing code */
  125.    } else {                      /* CHANGED line */
  126.      if(strstr(u.filename,".GIF"))         /* add */
  127.        w=42;                               /* add */
  128.      else                                  /* add */
  129.        w=58;                               /* add */
  130.      inputl(u.description,w);              /* add */
  131.    }                                       /* add */
  132.    if (u.description[0]==0)             /* existing code */
  133.      return(0);                         /* existing code */
  134.    ++thisuser.uploaded;                 /* existing code */
  135.    if (strstr(u.filename,".GIF"))          /* add */
  136.      check_gif(ff,u.description);          /* add */
  137.    thisuser.uk += ((l+1023)/1024);      /* existing code */
  138.  
  139. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  140. Step 5
  141.  
  142. SR.C
  143.  
  144. Block copy the following two functions to the end of SR.C
  145.  
  146.  
  147. int getbytes(FILE *dev)
  148. {
  149.     int byte1;
  150.     int byte2;
  151.     int result;
  152.  
  153.     /* read bytes and shift over */
  154.  
  155.     byte1 = getc(dev);
  156.     byte2 = getc(dev);
  157.  
  158.     result = (byte2 << 8) | byte1;
  159.  
  160.     return result;
  161.  
  162. }
  163.  
  164. void check_gif(char *fn, char *descript)
  165. {
  166.   int byte1, bits_per_pix,colors,i;
  167.   unsigned int width;
  168.   unsigned int height;
  169.   FILE *in;
  170.   char s[81];
  171.  
  172.   in = fopen (fn, "rb");
  173.   for (i = 0; (i < 6); i++) s[i] = getc(in);
  174.   s[6] = '\0';
  175.   width = getbytes(in);
  176.   height = getbytes(in);
  177.   byte1 = getc(in);
  178.   fclose(in);
  179.   if((strcmp(s,"GIF87a")) && (strcmp(s,"GIF89a"))) {
  180.     sprintf(s,"%s -- NOT a GIF file.",fn);
  181.     sysoplog(s);
  182.     return;
  183.   }
  184.   bits_per_pix = byte1 & 0x07;
  185.   bits_per_pix++;
  186.   colors = 1 << bits_per_pix;
  187.   if((width<1000) && (height<1000))
  188.     sprintf(s,"%dx%dx%-3d ... %s",width,height,colors,descript);
  189.   else {
  190.     if((width>999) && (height>999))
  191.       sprintf(s,"%dx%dx%-3d . %s",width,height,colors,descript);
  192.     if(((width>999) && (height<1000)) || ((width<1000) && (height>999)))
  193.       sprintf(s,"%dx%dx%-3d .. %s",width,height,colors,descript);
  194.   }
  195.   strcpy(descript,s);
  196. }
  197.  
  198. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  199.  
  200. And that's all! Just recompile your BBS and you are finished.
  201.  
  202. Note: You can put the two new functions anywhere, but because you put the two
  203.       new functions in FCNS.H, you must recompile the entire BBS.
  204.  
  205.  
  206.